/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    MP3MusicMate_v1.4.9
 *
 *    EasyBatteryRecommendConfig
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2011-12-16
 *    @version: 1.0
 *
 ******************************************************************************/

package great.app.luck.easybatteryrecommend;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * EasyBatteryRecommendConfig of MP3MusicMate_v1.4.9.
 * 
 * @author zuochen
 */

public class EasyBatteryRecommendConfig {
	static final String IS_FIRST_RUN_APP = "is_first_run_app";

	static final String IS_NEED_RECOMMEND = "is_recommend";

	static final String APP_RUN_TIME = "app_run_times";

	static final String RECOMMEND_APP_PACKAGE_ANME = "recommend_package_name";

	static final String DEFUALT_RECOMMEND_PACKAGE_NAME = "com.hot.free.defence.main";
	SharedPreferences mSharedPreferences;

	public EasyBatteryRecommendConfig(Context context) {
		mSharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(context);
	}

	public void saveRecommendPackageName(String packageName) {
		mSharedPreferences.edit()
				.putString(RECOMMEND_APP_PACKAGE_ANME, packageName).commit();
	}

	public String getRecommendPakcageName() {
		return mSharedPreferences.getString(RECOMMEND_APP_PACKAGE_ANME, DEFUALT_RECOMMEND_PACKAGE_NAME);
	}

	public boolean isFirstTimRunAPP() {
		return mSharedPreferences.getBoolean(IS_FIRST_RUN_APP, true);
	}

	public void changeIsFirstTimeRunAppState() {
		mSharedPreferences.edit().putBoolean(IS_FIRST_RUN_APP, false).commit();
	}

	public int getAppRunTimes() {
		return mSharedPreferences.getInt(APP_RUN_TIME, 0);
	}

	public void increaseAppRunTimes() {
		mSharedPreferences.edit().putInt(APP_RUN_TIME, getAppRunTimes() + 1)
				.commit();
	}

	public boolean isNeedRecommend() {
		return mSharedPreferences.getBoolean(IS_NEED_RECOMMEND, true);
	}

	public void changeNeedRecommendState() {
		mSharedPreferences.edit().putBoolean(IS_NEED_RECOMMEND, false).commit();
	}
}
